package com.bosssoft.hr.jobmonitor.config.common;

import com.bosssoft.hr.jobmonitor.core.auth.AuthInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @Author lys(cherish)
 * @Description 登入权限控制拦截器配置
 * @Date  2019/2/26
 **/
@Configuration
public class AuthInterceptorConfig extends WebMvcConfigurationSupport {

    /***
     * @Author lys(cherish)
     * @Description 拦截器添加方法
     * @Date  2019/2/26
     * @Param [registry] 拦截器注册器
     * @return void
     **/
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AuthInterceptor()).addPathPatterns("/**")
                .excludePathPatterns("/login/admin","/");
        super.addInterceptors(registry);
    }

    /***
     * @Author lys(cherish)
     * @Description 静态资源配置
     * @Date  2019/2/26
     * @Param [registry]拦截器注册器
     * @return void
     **/
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        super.addResourceHandlers(registry);
    }
}
